<template>
	<view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<goods-item  v-if="goodsList.length" :goodsList="goodsList" ></goods-item>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				goodsList:[],
				pageSize:20,
			}
		},
		methods:{
			downCallback(){
				this.mescroll.resetUpScroll();
			},
			upCallback(page){
				  this.$u.api.indexGoodsList({
						page:page.num,
						flags:'up_level',
					})
					.then(res=>{
					  this.mescroll.endBySize(this.pageSize, res.msg.totalPage);
					  if(page.num == 1){this.goodsList = [];} //如果是第一页需手动制空列表
					  this.goodsList =  this.goodsList.concat(res.msg.list); //如果是第一页需手动制空列表
				  })
				  .catch(()=>{
					//联网失败, 结束加载
					this.mescroll.endErr();
				  })
			}
		}
	}
</script>

<style>
</style>